#ifndef HTTP_CONTEXT_H
#define HTTP_CONTEXT_H
#include "http_request.h"

#include <QByteArray>

class HttpContext
{
public:
    HttpContext();
    ~HttpContext();

    // 检测HTTP是否解析完成
    bool gotAll() const {return m_state == HttpRequestDecodeState::kComplete;}
    // 解析HTTP报文
    void parseRequest(const QByteArray &data);
    // 重置状态
    void reset();

    const HttpRequest &request() const {return m_request;}
    HttpRequest &request() {return m_request;}
    // 调试打印http报文
    void debugPrintHttpMessage();

private:
    HttpRequestDecodeState m_state; //HTTP报文解析的状态
    HttpRequest m_request; //HTTP请求报文解析
};

#endif // HTTP_CONTEXT_H
